﻿using Common.Communal;
using ERP.Domain.System;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Api.Read.Applications.Commands.Permissions;

namespace System.Api.Read.Controllers
{
    /// <summary>
    /// 权限控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class PermissionController : ControllerBase
    {
        /// <summary>
        /// 中介者模式接口
        /// </summary>
        private readonly IMediator mediator;
        /// <summary>
        /// 构造函数，注入中介者模式接口
        /// </summary>
        /// <param name="mediator">中介者模式接口</param>
        public PermissionController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 获取权限
        /// </summary>
        /// <param name="command">命令</param>
        /// <returns>返回任务</returns>
        [HttpGet]
        public Task<ApiResult<List<Permission>>> GetPermission([FromQuery] PermissionQueryCommand command)
        {
            return mediator.Send(command);
        }
    }
}
